package com.gemme.gemme.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gemme.gemme.R;

public class SinChatView extends RelativeLayout {
    private Context context;
    Button button1;
    private ChatBean.DataBean.ListBeanX.ChatChildList.ListBean listBean;

    public SinChatView(Context context) {
        this(context,null);
    }

    public SinChatView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SinChatView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }

    TextView tv_name;
    TextView tv_desc;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.sin_chat_view,this);

        tv_name = findViewById(R.id.tv_name);
        tv_desc = findViewById(R.id.tv_desc);

    }

    public void setText(String text){
        button1.setText(text);
    }

    public void setData(ChatBean.DataBean.ListBeanX.ChatChildList.ListBean listBean) {
        this.listBean = listBean;
        try {
            String userName = listBean.getUserName();
            String toUserName = listBean.getToUserName();
            tv_name.setText(
                    TextUtils.isEmpty(toUserName) ?  userName+ " : " :
                            userName +"回复" +toUserName + " : ");
            tv_desc.setText(listBean.getComments());
        }catch (Exception e){

        }
    }

    public ChatBean.DataBean.ListBeanX.ChatChildList.ListBean getData(){
        return listBean;
    }
}
